package com.gdziarmaga.webshop.delivery.model;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.gdziarmaga.webshop.core.dao.GenericDaoImpl;

@Repository("deliveryRepo")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class DeliveryDAOImpl extends GenericDaoImpl<Delivery, Long> implements DeliveryDAO {

	@Override
	public Delivery findProductByInvoice_number(String invoice_number) {
		return getObjectByCriteria(createDetachedCriteria().add(Restrictions.eq(Delivery.INVOICE_NUMBER, invoice_number)));
	}

	@Override
	public Delivery findProductBySupplier_name(String supplier_name) {
		return getObjectByCriteria(createDetachedCriteria().add(Restrictions.eq(Delivery.SUPPLIER_NAME, supplier_name)));
	}
}
